<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <button type="button">按键1</button>
        <button type="button">按键2</button>
        <button type="button">按键3</button>
        <button type="button">按键4</button>
        <button type="button">按键5</button>
    </div>
    <script>
        var btns=document.getElementsByTagName('button');
        for(let i=0;i<btns.length;i++){
            btns[i].onclick=function(){
                for(let j=0;j<btns.length;j++){
                    btns[j].style.backgroundColor='';
                }

                this.style.backgroundColor='pink'
            }
        }
    </script>
</body>
</html>